package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.eduservice.entity.subject.OneSubject;
import com.atguigu.eduservice.service.EduSubjectService;
import com.atguigu.eduservice.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2021-12-10
 */
@RestController
@RequestMapping("/eduService/subject")
@CrossOrigin
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;

    //添加课程分类
    //获取上传文件,把文件内容读取
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
    //        MultipartFile file 上传的文件
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();
    }

    //实现树形结构分类
    //创建实体类
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        List<OneSubject> subjects = eduSubjectService.getAllOneTwoSubject();
        return R.ok().data("list",subjects);
    }

}

